package com.hmx.openplatform.eureka.conf;

import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

/**
 * Description:
 *
 * @author hmx
 * @date Created on 2021/5/21
 */

/**
 * 我们的eureka的配置，防止无法注册服务
 */
@EnableWebSecurity
public class EurekaConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.csrf().disable() //禁用掉csrf防攻击，放置我们的服务无法注册
                .authorizeRequests()// 需要认证所有的请求
                .mvcMatchers("/eureka/**").permitAll()// 注册地址放行
                .mvcMatchers("/actuator/**").permitAll()//
                .anyRequest().authenticated().and().httpBasic();
    }
}
